'********************************************************************************
' Mindfly, Inc - http://www.mindfly.com
' Copyright (c) 2006
' by Mindfly Inc. ( http://www.mindfly.com )
'
' Remarks   
' Reworked: 11/30/2006
'********************************************************************************

Imports System.Configuration
Imports System.Web.Configuration

Namespace Configuration


    Public Class ProviderElement
        Inherits ConfigurationElement


        ''' <summary>
        ''' Key value for the component colleciton
        ''' </summary>
        ''' <value>String</value>
        ''' <returns>String</returns>
        ''' <remarks>rss - 11/29/2006</remarks>
        <ConfigurationProperty("name", iskey:=True)> _
        Public Property Name() As String
            Get
                Return Me("name").ToString
            End Get
            Set(ByVal value As String)
                Me("name") = value
            End Set
        End Property


        ''' <summary>
        ''' Retrieves the configured connection string for the SiteMapProvider configured
        ''' </summary>
        ''' <value>String</value>
        ''' <returns>Connection String (string)</returns>
        ''' <remarks>rss - 8/14/2006</remarks>
        <ConfigurationProperty("connectionStringName")> _
        Public ReadOnly Property ConnectionString() As String
            Get
                Dim ConnStringName As String
                If String.IsNullOrEmpty(Me("connectionStringName")) Then
                    ConnStringName = Globals.Settings.defaultConnectionStringName
                Else
                    ConnStringName = Me("connectionStringName")
                End If
                Return WebConfigurationManager.ConnectionStrings(ConnStringName).ConnectionString

            End Get
        End Property


        ''' <summary>
        ''' Retrieves the configured Provider Type
        ''' </summary>
        ''' <value>String</value>
        ''' <returns>Provider Type Name</returns>
        ''' <remarks>rss - 11/29/2006</remarks>
        <ConfigurationProperty("providerType", isrequired:=True)> _
        Public Property ProviderType() As String
            Get
                Return CType(Me("providerType"), String)
            End Get
            Set(ByVal value As String)
                Me("providerType") = value
            End Set
        End Property


        ''' <summary>
        ''' Retrieves the configuration value enableCaching (boolean)
        ''' </summary>
        ''' <value>Boolean</value>
        ''' <returns>Boolean</returns>
        ''' <remarks>rss - 8/14/2006</remarks>
        <ConfigurationProperty("enableCaching", DefaultValue:="true")> _
        Public Property EnableCaching() As Boolean
            Get
                Return CType(Me("enableCaching"), Boolean)
            End Get
            Set(ByVal value As Boolean)
                Me("enableCaching") = value
            End Set
        End Property


        ''' <summary>
        ''' Retrieves the configuration value enableCaching (boolean)
        ''' </summary>
        ''' <value>Boolean</value>
        ''' <returns>Boolean</returns>
        ''' <remarks>rss - 8/14/2006</remarks>
        <ConfigurationProperty("enableListCaching", DefaultValue:="true")> _
        Public Property EnableListCaching() As Boolean
            Get
                Return CType(Me("enableListCaching"), Boolean)
            End Get
            Set(ByVal value As Boolean)
                Me("enableListCaching") = value
            End Set
        End Property


        ''' <summary>
        ''' Cache duration for this component
        ''' </summary>
        ''' <value>Integer</value>
        ''' <returns>Integer</returns>
        ''' <remarks>rss - 8/14/2006</remarks>
        <ConfigurationProperty("cacheDuration")> _
        Public Property CacheDuration() As Integer
            Get
                Dim iCacheDuration As Integer = CType(Me("cacheDuration"), Integer)
                If iCacheDuration > 0 Then
                    Return iCacheDuration
                Else
                    Return Globals.Settings.DefaultCacheDuration
                End If
            End Get
            Set(ByVal value As Integer)
                Me("cacheDuration") = value
            End Set
        End Property

    End Class

End Namespace
